<?php

/**
 * LEAGUEMan
 * 
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$teams	= $this->project->getTeams("team_id");

?>

<table class="contentpaneopen">

<?php		

$goals		= 0;
$match_date = "";
$v 			= 0;

foreach($this->matches as $match){
	
	if($match_date != $match->match_date){
		$match_date = $match->match_date;
		
		?>
		
		<tr>
			<td colspan="5" class="sectiontableheader"><?php echo strftime("%A, %d.%m.%Y", strtotime($match_date));?></td>
		</tr>
		
	<?php
	}
	
	if(is_numeric($match->match_result_0_1) && is_numeric($match->match_result_0_2)){
		$goals = $goals + $match->match_result_0_1 + $match->match_result_0_2;
		$v++;
	}
	
?>
	<tr class="<?php $this->plugin("toggle", "sectiontableentry1", "sectiontableentry2");?>">
		<td width="10%"><?php echo strftime("%H:%M", strtotime($match->match_date . " " . $match->match_time));?></td>
		<td width="30%" align="right">
			<?php $this->plugin("leagueman_get_teaminfo_link", $teams, $match->team1_id, $match->team1_name, 0, $this->Itemid);?>&nbsp;
			<?php $this->plugin("thumb", "logos", $match->team1_logo, 18, 18); ?>
		</td>
		<td width="2%" align="center">-</td>
		<td width="30%" align="left">
			<?php $this->plugin("thumb", "logos", $match->team2_logo, 18, 18); ?>&nbsp;
			<?php $this->plugin("leagueman_get_teaminfo_link", $teams, $match->team2_id, $match->team2_name, 0, $this->Itemid);?>
		</td>
		<td nowrap="nowrap">
			<?php $this->plugin("leagueman_get_match_result", $match, 0)?>&nbsp;
			<?php $this->plugin("leagueman_get_match_result", $match, $this->project->getParam("cnt_chapters", 0));?>
		</td>
	</tr>
<?php

}
	
?>
	<tr>
		<td class="sectiontableheader" colspan="5">
			<div align="center">
				<?php printf("%s: %s (%1.2f %s)", _LM_TOTALGOALS, $goals, $this->splugin("leagueman_get_avg", $goals, $v), _LM_PERMATCH); ?>
			</div>
		</td>
	</tr>
</table>